import './index.less';

import React from 'react';
import { inject, observer } from 'mobx-react';

import { Modal, Row, Col, Button, Popover, message, Spin, Checkbox, Icon,Radio } from 'antd';
import {
    WeaTools,
    WeaRightMenu,
    WeaBrowser,
    WeaLocaleProvider,
    WeaPopoverHrm,
    WeaCheckbox,
    WeaInput,
    WeaInputNumber,
    WeaDialog,
    WeaDatePicker,
} from 'ecCom'
import objectAssign from 'object-assign';
import * as SignUtil from '../../util/signUtil';
import SignInputck from '../wf-sign-input/index';
import RemindTypelist from '../wf-remind-typelist';

import trim from 'lodash/trim'
import isEqual from 'lodash/isEqual';
import * as mobx from 'mobx';
import { toJS, observable } from 'mobx'

const warning = Modal.warning;
const confirm = Modal.confirm;
const getLabel = WeaLocaleProvider.getLabel;
const RadioGroup = Radio.Group;

@observer
export default class GWForwardck extends React.Component {
    constructor(props) {
        super(props);
    }

  render () {
      //inOdoc 是否是公文使用
        let { wfForwardGWStore,inOdoc = false,isPrintShow=false} = this.props;
        const {
            showGwForward,
            signinput = {},
            loading,
            loaded,
            isClear,
            formParams = {},
            initRemarkContent,
            remarkMap,
            chuanyueInfo,
            remindTypes,
            replyNoticeInfo = {},
            fwLimitInfo = {},
            isFormSignature,
            showhfsx,
            showhfdw,
            showbjdw,
            onGwzbClfsChange,
            gwzbDatas
        } = wfForwardGWStore;
        let {remindInfo} = wfForwardGWStore;
        const { use_textarea_signinput, isannexupload_edit, isSignDoc_edit, isSignWorkflow_edit,remarkInfo={} , isSignLocation_edit } = signinput;
        const { handWrittenSignSwitch } = remarkInfo;
        const { requestid = -1 ,remark = '', workflowRequestLogId} = formParams;
        const  {userSubCompanyName,loadLogList}   =gwzbDatas;

        const { isforwardrights = '', requestname = '', isHideInput = '' } = signinput;
        const remarkMustInput = this.verifyRemarkMustInput(signinput);

        let _forwardheight = isforwardrights == '1' ? 479 : 439;
        const ishideinput = isHideInput == '1';
        if (ishideinput) {
            _forwardheight = _forwardheight - 175;
        }
        remindInfo = {...remindInfo,...{value : remindTypes}};

        let isHasRemark = false;
        let i = 0;
        remarkMap.forEach((value, key, map) => {
            if (key) {
                i++;
            }
        })
        if (JSON.stringify(toJS(remarkMap)) === "{}" || (toJS(remarkMap).key_0 === '' && i <= 1)) {
            isHasRemark = false;
        } else {
            isHasRemark = true;
        }

        const agent = (
            <span style={{ color: "#A0A0A0" }}>{getLabel(388045, "您当前正在代理")}
                <a href={`javaScript:openhrm(${signinput.tempbeagenter});`} onClick={e => window.pointerXY(e)} title={signinput.tempbeagentername}>
                    <span style={{ color: "#4D7AD8", verticalAlign: "initial", cursor: "pointer", marginLeft: "0" }}>{signinput.tempbeagentername}</span>
                </a>
                {getLabel(84398, "进行操作")}</span>
        )

        let compHeight = '195px';
        if(isFormSignature==1){
            if(!this.hasBottomConfig()){
                compHeight = "260px";
            }else{
                if(use_textarea_signinput == 1){
                    compHeight = "290px";
                }else{
                    compHeight = "300px";
                }
            }
        }else {
            if(use_textarea_signinput == 1){
                compHeight = '260px';
            }else if (handWrittenSignSwitch == 1 || isannexupload_edit|| isSignDoc_edit|| isSignWorkflow_edit ||  isSignLocation_edit == 1){
                compHeight = '250px';
            }else {
                compHeight = '195px';
            }
        }
        const tabs = [{
            "dataParams": {
                "cmd": "List"
            },
            "isSearch": true,
            "key": "1",
            "name": "列表",
            "selected": false,
            "showOrder": 0
        }, {
            "dataParams": {
                "cmd": "Organization"
            },
            "isSearch": false,
            "key": "2",
            "name": "组织结构",
            "selected": false,
            "showOrder": 0
        }, {
            "dataParams": {
                "cmd": "PublicGroup"
            },
            "isSearch": false,
            "key": "3",
            "name": "公共组",
            "selected": false,
            "showOrder": 0
        }, {
            "dataParams": {
                "cmd": "PrivateGroup"
            },
            "isSearch": false,
            "key": "4",
            "name": "私人组",
            "selected": false,
            "showOrder": 0
        }, {
            "dataParams": {
                "companyType": "1",
                "cmd": "ExternalUnit"
            },
            "isSearch": false,
            "key": "5",
            "name": "外部单位",
            "selected": false,
            "showOrder": 0
        }];
        return (
            <div>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@fl8ao4`}
                    title={this.getTopTitle(requestname, ishideinput,isPrintShow)}
                    visible={showGwForward}
                    parentClassName="wf-req-gwforward-dialog"
                    style={{ width: ishideinput ? 800 : 1100, padding: "10px 20px"  }}
                    maskClosable={false}
                    onCancel={this.cancelEvent}
                    buttons={[
                               <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@2acct3@submit`} type="primary" size="large" disabled={loading} onClick={isPrintShow?this.printEvent:this.submitEvent}>{isPrintShow?getLabel('502295', "打印"):getLabel('83446', "确定")}</Button>,
                               <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@qa2dp5@cancel`} type="ghost" size="large" disabled={loading} onClick={this.cancelEvent}>{getLabel('500944', "取消")}</Button>
                           ]
                    }
                    icon="icon-coms-workflow"
                    iconBgcolor='#0079DE'
                    loadCss={true}
                    initLoadCss={true}
                    //在公文使用该弹窗的时会出现弹窗遮盖的问题 加inOdoc控制渲染的dom--康乐
                    layout={typeof jQuery('.wf-req')[0] == 'undefined' && !inOdoc ? jQuery('#container')[0] : jQuery('.wf-req')[0]}
                >
                <div className="wea-req-gwforward-modal" style={{width:"100%",height:"100%"}}>
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@tmzdra`} width={165} datas={this.getRightMenu()} onClick={this.onRightMenuClick}>
                        <div>
                            <RemindTypelist ecId={`${this && this.props && this.props.ecId || ''}_GWRemindTypelist@jvuep2`} {...remindInfo} callbackFun={(v)=>{
                                wfForwardGWStore.updateRemindType(v);
                            }} />
                        </div>
                        <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@thwvft`} spinning={loading}>
                            <div className="wea-req-forward-content">
                                        <table cellSpacing="0" cellPadding="0"  className="gwzbtable" style={{"display":isPrintShow?"none":""}}> 
                                            <tr>
                                                <td className="gwzbtdlabel">{getLabel('533193', "转办名义")}</td>
                                                <td className="gwzbtdinfo" colSpan="3">
                                                    {userSubCompanyName}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td className="gwzbtdlabel" >{getLabel('513766', "处理意见")}<span className="gwzbbt">*</span></td>
                                                <td className="gwzbtdinfo" colSpan="3">
                                                    <div className="wea-req-forward-content-remark" style={{ 'display': ishideinput ? 'none' : 'block' }}>
                                                            <div className='remark' id="forwardremark_div" style={{ height: compHeight }}>
                                                                {loaded && !ishideinput &&
                                                                    <SignInputck ecId={`${this && this.props && this.props.ecId || ''}_SignInputck@abvafa`}
                                                                        markInfo={signinput}
                                                                        isShowSignInput={true}
                                                                        editorId={'forwardremark'}
                                                                        maxHeight={150}
                                                                        visible={showGwForward}
                                                                        ref={"formwardRemarkCK"}
                                                                        isClear={isClear}
                                                                        requestid={requestid}
                                                                        initRemarkContent={initRemarkContent}
                                                                        remark={remark}
                                                                        workflowRequestLogId={workflowRequestLogId}
                                                                        globalStore={this.props.globalStore}
                                                                        layout={window}
                                                                        saveCallBack={() => {
                                                                            wfForwardGWStore.initData();
                                                                            this.props.globalStore.loadMarkInfo();
                                                                        }}
                                                                    />
                                                                }
                                                            </div>
                                                        </div>
                                                        <div style={{ 'width': '100%', 'height': '20px' }}></div>
                                                        {ishideinput && <div style={{ 'width': '100%', 'height': '40px' }}></div>}
                                                </td>
                                            </tr>
                                            <tr>
                                                <td className="gwzbtdlabel">{getLabel('124780', "处理方式")}<span className="gwzbbt">*</span></td>
                                                <td className="gwzbtdcslxinfo" style={{"width":"40%"}}>
                                                    <RadioGroup onChange={onGwzbClfsChange} >
                                                        <Radio key="xyhf" value={0}>需要回复</Radio>
                                                        <Radio key="bj" value={1}>办结</Radio>
                                                    </RadioGroup>
                                                </td>
                                                <td className="gwzbtdlabel">
                                                {getLabel('533197', "回复时限")} {showhfsx&&<span className="gwzbbt">*</span>}
                                                </td>
                                                <td className="gwzbtdinfo" style={{"width":"40%"}}>
                                                {showhfsx&&<WeaDatePicker   viewAttr={3} onChange={this.onGWZBhfsjChnage.bind(this)} /> } 
                                                </td>
                                            </tr>
                                            <tr>
                                                <td className="gwzbtdlabel">{getLabel('533198', "转办回复单位")}{showhfdw&&<span className="gwzbbt">*</span>}</td>
                                                <td  className="gwzbtdinfo" colSpan="3">
                                                {showhfdw&&<WeaBrowser type="142" fieldName="zbhfdw" viewAttr="3" isSingle={false} title={getLabel('19309', "收（发）文单位")} 
                                                    ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@vyk6y2`}
                                                    linkUrl="/spa/odoc/static/index.html#/main/offical/recPostUnit?receiveUnitId="
                                                    tabs={tabs}
                                                    inputStyle={{"width":"200px"}}
                                                    onChange={this.onGWZbhfdwChange.bind(this)}
                                                    />} 
                                                </td>
                                            </tr>
                                            <tr>
                                                <td className="gwzbtdlabel">{getLabel('533199', "转办办结单位")}{showbjdw&&<span className="gwzbbt">*</span>}</td>
                                                <td  className="gwzbtdinfo" colSpan="3">
                                                    <WeaBrowser type="142" fieldName="zbbjdw" viewAttr={showbjdw?3:2}  isSingle={false} title={getLabel('19309', "收（发）文单位")}
                                                    ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@zjk6y2`} 
                                                    linkUrl="/spa/odoc/static/index.html#/main/offical/recPostUnit?receiveUnitId="
                                                    tabs={tabs}
                                                    inputStyle={{"width":"200px"}}
                                                    onChange={this.onGWZbbjdwChange.bind(this)}
                                                    />
                                                </td>
                                            </tr>
                                            {/*<tr>
                                                <td className="gwzbtdlabel">{getLabel('533200', "发送反馈意见")}</td>
                                                <td colSpan="3">
                                                    <RadioGroup onChange={this.onGWZbfsfkyjChange.bind(this)}>
                                                        <Radio key="fsfkyj1" value={1}>是</Radio>
                                                        <Radio key="fsfkyj0" value={0}>否</Radio>
                                                    </RadioGroup>
                                                </td>
                                            </tr>*/}
                                            <tr>
                                                <td className="gwzbtdlabel">{getLabel('533201', "发送收文附件")}<span className="gwzbbt">*</span></td>
                                                <td  className="gwzbtdcslxinfo" colSpan="3">
                                                <RadioGroup defaultValue={1} onChange={this.onGWZbfssfwfjChange.bind(this)}>
                                                        <Radio key="fsswfj1" value={1}>是</Radio>
                                                        <Radio key="fsswfj0" value={0}>否</Radio>
                                                </RadioGroup>
                                                </td>
                                            </tr>
                                        </table>
                            <table  cellSpacing="0" cellPadding="0" className="gwzbtable">
                                <thead>
                                <tr>
                                <th className="gwzbthlabel">{getLabel('519096', "请选择")}</th>
                                <th className="gwzbthlabel">{getLabel('528219', "序号")}</th>
                                <th className="gwzbthlabel">{getLabel('2172', "执行人")}</th>
                                <th className="gwzbthlabel">{getLabel('533202', "承办单位")}</th>
                                <th className="gwzbthlabel">{getLabel('513766', "处理意见")}</th>
                                </tr>
                                </thead>
                                <tbody>
                                    {loadLogList&&loadLogList.map((item,index)=>{
                                         return <tr className={index%2==0?"":"gwzbtdone"}>
                                                     <td className="gwzbtdinfo" style={{"text-align":"center"}}><Checkbox  value={item.logid} id="logidck"  onChange={this.onGWZBCkChange.bind(this)} ></Checkbox></td>
                                                     <td className="gwzbtdinfo" style={{"text-align":"center"}}>{item.rowNum}</td>
                                                     <td className="gwzbtdinfo" style={{"text-align":"center"}}>{item.operatorName}</td>
                                                     <td className="gwzbtdinfo" style={{"text-align":"center"}}>{item.operatorDept}</td>
                                                     <td className="gwzbtdinfo" style={{"text-align":"center"}}>{item.remark}</td>
                                                </tr>;
                                    })}
                                </tbody>
                                </table>
                           </div>
                        </Spin>
                    </WeaRightMenu>
                 </div>
                </WeaDialog>
            </div>
        )
    }

    onGWZBCkChange(e){
        const {gwFormParams}= this.props.wfForwardGWStore;
        const {logs} = gwFormParams;
        if(e.target.checked){
            if(logs.includes(e.target.value)){
                logs.remove(e.target.value);
            }
            logs.push(e.target.value);
        }else {
            logs.remove(e.target.value);
        }
    }

    onGWZbfssfwfjChange(e){
        const {gwFormParams}= this.props.wfForwardGWStore;
        gwFormParams.fsswfj=e.target.value;
    }

    onGWZbfsfkyjChange(e){
        const {gwFormParams}= this.props.wfForwardGWStore;
        gwFormParams.fsfkyj=e.target.value;
    }

    onGWZbbjdwChange(ids, names, datas){
        const {gwFormParams}= this.props.wfForwardGWStore;
        gwFormParams.zbbjdw=ids;
        gwFormParams.zbbjdwSpan=names;

    }
    onGWZbhfdwChange(ids, names, datas){
        const {gwFormParams}= this.props.wfForwardGWStore;
        gwFormParams.zbhfdw=ids;
        gwFormParams.zbhfdwSpan=names;
    }

    onGWZBhfsjChnage(value){
        const {gwFormParams}= this.props.wfForwardGWStore;
        gwFormParams.hfsx=value;
    }

    

    hasBottomConfig = () => {
        let { wfForwardGWStore,} = this.props;
        const { signinput = {} } = wfForwardGWStore;
        const { use_textarea_signinput, isannexupload_edit, isSignDoc_edit, isSignWorkflow_edit,remarkInfo={} ,isFormSignature, isSignLocation_edit } = signinput;
        const { handWrittenSignSwitch } = remarkInfo;
        let flag = false;
        if (isannexupload_edit == true|| isSignDoc_edit == true || isSignWorkflow_edit == true || isSignLocation_edit == true || handWrittenSignSwitch == 1){
            flag=true;
        }
        return flag;
    }
    

    updateFormParams(paramKey, o) {
        const { wfForwardGWStore } = this.props;
        const { setFormParams } = wfForwardGWStore;
        const updateParams = {};
        if (paramKey === 'IsSubmitedOpinion' || paramKey === 'IsBeForwardTodo'
            || paramKey === 'isSubmitSign' || paramKey === 'isChuanyue'
            || paramKey === 'isShowReplyNotice' || paramKey === 'isRemind') {
            updateParams[paramKey] = o.target.checked ? 1 : 0;
            // if(paramKey === 'IsSubmitedOpinion'){
            //     //关闭转发可提交意见时，也关闭转发接收人批注时提醒我
            //     updateParams['isShowReplyNotice'] = o.target.checked ? 1 : 0;
            // }
        } else {
            updateParams[paramKey] = o;
        }
        setFormParams(updateParams);
    }

    onCKEditorChange(datas) {
        //this.setState(datas);
    }

    onRightMenuClick = () =>  {
        const { isPrintShow } = this.props;
       if(isPrintShow){
             this.printEvent();
        }else{
           this.submitEvent();
        }
    }

    getRightMenu() {
        const { wfForwardGWStore,isPrintShow } = this.props;
        const { loading } = wfForwardGWStore;
        let btnArr = [];
        if(isPrintShow){
            btnArr.push({
                icon: <i className={`icon-workflow-Right-menu-Need-feedback`} />,
                content: getLabel('502295', "打印"),
                disabled: loading
            });
        }else{
            btnArr.push({
                icon: <i className={`icon-workflow-Right-menu-Need-feedback`} />,
                content: getLabel('83446', "确认"),
                disabled: loading
            });
        }
       
        return btnArr;
    }

    getTopTitle(titlename, ishideinput,isPrintShow) {
        const { wfForwardGWStore } = this.props;
        const { formParams = {}, signinput = {}} = wfForwardGWStore;
        const { feedbacksign = '' } = formParams;

        //自定义按钮信息
        const {customBtnInfo = {}} = signinput;
        const {titlenameprefixInfo = {} ,} = customBtnInfo;

        let titlenameprefix = `${getLabel('533174', "公文转办")}`
        if(isPrintShow){
            titlenameprefix = `${getLabel('513622', "打印呈批表")}`
        }

        return (
            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@y8x4a3`}>
                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@16m77u`} span="22" style={{ lineHeight: "45px", width: ishideinput ? '700px' : '1000px' }}>
                    {/* <div className="wea-workflow-icon">
                        <i className='icon-portal-workflow' />
                    </div> */}
                    <div className="wf-forward-title" style={{ width: ishideinput ? '635px' : '935px' }} title={titlename} dangerouslySetInnerHTML={{ __html: titlenameprefix  }}></div>
                </Col>
            </Row>
        )
    }

    verifyRemarkMustInput(signinput = {}){
        const {signMustInputTypes = [],isSignMustInput = '', isFormSignature = ""} = signinput;
        if(isSignMustInput == '1') {
            return true;
        } else if(isSignMustInput == '2') {
            return true;
        } else {
            return true;
        }
    }
    
    //打印
    printEvent = () =>  {
        const {gwurl} = this.props;
        const {gwFormParams}= this.props.wfForwardGWStore;
        const {logs} = gwFormParams;
        if(logs.length>0){
             this.cancelEvent();
             const { globalStore } = this.props;
             const { commonParam , urlParams = {}} =globalStore;
             const { requestid,wfmonitor,isurger,f_weaver_belongto_userid,f_weaver_belongto_usertype,wfTestStr } = commonParam;
             const { isrequest = '',isfromreport='',reportid='',isfromflowreport='', isfromchatshare=''} = urlParams;
             if(gwurl!=''){
                 let gwprintUrl = gwurl;
                if(logs) gwprintUrl += `&signFilterlogids=${logs.join(",")}`;
                var win = window.open(gwprintUrl,requestid);
		    	win.location.reload();
             }else{
                 
                    let { authSignatureStr = '',authStr = '' } = urlParams;
                    if (!authSignatureStr) authSignatureStr = commonParam.authSignatureStr;
                    if (!authStr) authStr = commonParam.authStr;
                    const ismonitor = wfmonitor ? "1" : "0";
                    const urger = isurger ? "1" : "0";
                    const printurl = "/workflow/request/PrintRequestForward.jsp?";
                    let printUrlParams = `requestid=${requestid}&ismonitor=${ismonitor}&urger=${urger}&f_weaver_belongto_userid=${f_weaver_belongto_userid}&f_weaver_belongto_usertype=${f_weaver_belongto_usertype}&wfTestStr=${wfTestStr}`;
                    if(authSignatureStr) printUrlParams += `&authSignatureStr=${authSignatureStr}`;
                    if(authStr) printUrlParams += `&authStr=${authStr}`;
                    if(isrequest) printUrlParams += `&isrequest=${isrequest}`;
                    if(isfromreport) printUrlParams += `&isfromreport=${isfromreport}`;
                    if(isfromflowreport)printUrlParams += `&isfromflowreport=${isfromflowreport}`;
                    if (isfromchatshare) printUrlParams += `&isfromchatshare=${isfromchatshare}`;
                    if(reportid) printUrlParams += `&reportid=${reportid}`;
                    if(logs) printUrlParams += `&signFilterlogids=${logs.join(",")}`;
                    openFullWindowHaveBar(printurl+printUrlParams);
            }
        }else{
            this.cancelEvent();
        }
    }

    //提交
    submitEvent = () =>  {
        const { wfForwardGWStore } = this.props;
        const { globalStore } = this.props;
        let openByDefaultBrowser = '';
        if(globalStore){
            const { submitParam } = globalStore;
            openByDefaultBrowser = submitParam.openByDefaultBrowser;
        }
        const { showhfsx,showhfdw,showbjdw,operatorDatas, signinput = {}, formParams = {},gwFormParams={}, requestType, currentnodetype, doSubmitPost } = wfForwardGWStore;
        const { field5, IsSubmitedOpinion, IsBeForwardTodo } = formParams;
        const {clsf,hfsx,zbhfdw,zbbjdw,fsfkyj,fsswfj} = gwFormParams; 
        const {signMustInputTypes = [],isSignMustInput = '', isFormSignature = "", customBtnInfo = {}} = signinput;
        const { overTimeTakInfo = {}, btnNameInfo = {} } = customBtnInfo;
        let forwardremarkInfo = this.getSignInputInfo();
        //验证签字意见必填
        let flag = true;
        if (this.verifyRemarkMustInput(signinput) && isFormSignature!='1') {
            let forwardremarkcontent = window.CK_REF.forwardremark.getEditor().getData();
            flag = SignUtil.chekcremark(forwardremarkcontent, forwardremarkInfo);
        }else if(forwardremarkInfo==false && isFormSignature=='1') {
            //签章必填已经在getSignInputInfo中提示了，直接return即可
           return;
        }
        
        if ((!flag && isFormSignature!='1') 
               ||(clsf!='0'&&clsf!='1')||(showhfsx&&hfsx=='')|| (showhfdw&&zbhfdw=='')
               || (showbjdw&&zbbjdw=='') ||fsswfj=='' ) {
            message.warning(getLabel(384146, '必要信息不完整，红色*号为必填项！'), 2);
            return;
        }

        const forwardPara = {};
        forwardPara.openByDefaultBrowser = openByDefaultBrowser;
        if (currentnodetype == "3") { //办结
            forwardPara.IsBeForwardSubmitNotaries = IsSubmitedOpinion;
            forwardPara.IsBeForward = IsBeForwardTodo;
        } else {
            if (requestType == "1") { //待办
                forwardPara.IsSubmitedOpinion = IsSubmitedOpinion;
                forwardPara.IsBeForwardTodo = IsBeForwardTodo;
            } else { //已办
                forwardPara.IsBeForwardSubmitAlready = IsSubmitedOpinion;
                forwardPara.IsBeForwardAlready = IsBeForwardTodo;
            }
        }
        //在这里把签字意见引用加上，字段为remark
        let params = objectAssign({}, { 
            operate: 'save',
            field5: field5
        }, forwardPara, formParams,gwFormParams,forwardremarkInfo);
        const _this = this;
        if (signinput.needconfirm === "1") {
            confirm({
                zIndex: 1050,
                content: getLabel('519085', "确认是否{1}？").replace("{1}", btnNameInfo[3]),
                onOk() {
                   doSubmitPost(params);
                },
                onCancel() { }
            });
        } else {
            doSubmitPost(params);
        }
    }

    contentUtil = (str) => {
      let head = str.substr(0, str.indexOf("<div _quotoContent='true'"));
      str = str.slice(str.indexOf("<div _quotoContent='true'"));
      let pic = `[${getLabel(528760 , '图片')}]`;
      str = str.replace(/<img.*?>/g, pic)
      str = str.replace(/<[^>]*>|<\/[^>]*>/gm, "")
      str = str.replace(/\r|\n|\\s/gm, "");
      str = '<div class="remark-quote">' + str + '</div>'
      str = head + str  + "</div>";
      return str;
  }

    // 点击删除一个签字意见
    deleteItem(key, event) {
        const { wfForwardGWStore } = this.props;
        const { remarkMap } = wfForwardGWStore;
        remarkMap.delete(key);
    }
    //渲染引用签字意见列表
    getRemarkDom =
        () => {
            const { wfForwardGWStore } = this.props;
            const { remarkMap } = wfForwardGWStore;
            let arr = [];
            remarkMap.forEach((value, key, map) => {
                const item = <div className='remark_list_dom' style={{ position: "relative" }}>
                    <div dangerouslySetInnerHTML={{ __html: this.contentUtil(value) }}></div>
                    <Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@tb2va6@${key}`} type="cross" className="wf-req-sign-input-delete" onClick={this.deleteItem.bind(this, key)} />
                </div>
                if (value !== '') {
                    arr.push(item)
                }
            })
            return arr;
        }

    getSignInputInfo() {
        const { wfForwardGWStore } = this.props;
        const { formParams = {}, signinput = {}, remarkMap} = wfForwardGWStore;
        const { isHideInput = '' ,extendParams = {},use_textarea_signinput = 0, isFormSignature = '',isSignMustInput=''} = signinput;
        if (isHideInput == '1') return {};
            const ckState = this.refs.formwardRemarkCK.state;
            const { requestid = -1 } = formParams;
            const { signworkflowids = '', signdocids = '', remarkLocation = '', annexdocinfos = [], signdocreplacedata = [], signworkflowreplacedata = [], signhandwrittenid} = ckState;
            const annexdocids = [];
            annexdocinfos.map(o => annexdocids.push(o.fileid));
            let params = {
                signworkflowids: signworkflowids,
                signdocids: signdocids,
                remarkLocation: remarkLocation,
                'field-annexupload': annexdocids.join(','),
                'field-annexupload-request': requestid,
                handWrittenSign:signhandwrittenid,
            }
            if(isFormSignature == '1'){
                const isSignatureMustInput = this.verifyRemarkMustInput(signinput);
                if(window.saveAutographMul && window.saveAutographMul.wfWeaAutographCompforwardremark){
                    let requestlog = window.saveAutographMul.wfWeaAutographCompforwardremark(isSignatureMustInput)
                    if(requestlog === true || requestlog == -1){
    
                    }else if(!isNaN(requestlog) && parseInt(requestlog) > 0){
                        params.workflowRequestLogId=requestlog;
                    }else{
                        if(requestlog == "-2")
                            message.warning(getLabel(386186,'"签字意见"未填写'), 2);
                        else
                            message.warning(getLabel(528568,"签章保存失败"), 2);
                        return false;
                    }
                }
            }else{
                const remark = window.CK_REF.forwardremark.getEditor().getData();
                let _remark = remark.replace(/​/ig, ''); //&#8203\
        
                const {wfSignDefaultFontFamily = '',wfSignDefaultFontSize = ''} = extendParams;
                _remark = SignUtil.appendDefaultSytle(_remark,wfSignDefaultFontFamily,wfSignDefaultFontSize,use_textarea_signinput);
                let tt = '';
                remarkMap.forEach((value, key, map) => {
                    tt += value;
                })
                _remark = tt + _remark;
                params.remark = _remark;
            }
            return params;
    }

    cancelEvent = () =>  {
        const { wfForwardGWStore } = this.props;
        const {setFormParams,closeForwarDialog,callBackActions = {},signinput, setSignInput} = wfForwardGWStore;
        const {isFormSignature="",isSignMustInput=""}=signinput;
        if(window.CK_REF && window.CK_REF.forwardremark && window.CK_REF.forwardremark.getEditor()) {
            const remark = window.CK_REF.forwardremark.getEditor().getData();
            let _remark = remark.replace(/​/ig, ''); //&#8203\
            setFormParams({remark:_remark});
        }
        if(signinput.isFormSignature==1){
                const requestlog = window.saveAutograph(false,true);
                if(requestlog.indexOfAutograph == 'wfWeaAutographCompforwardremark'){
                    setFormParams({workflowRequestLogId:requestlog.recordId });
                }
            }
        wfForwardGWStore.setShowForward({ showGwForward: false, requestid: -1,isClickCloseBtn:true });
        //关闭窗口，将ReqIndex.js中的参数也修改，避免出现问题
        if (closeForwarDialog && typeof closeForwarDialog == "function") {
            closeForwarDialog();
        }
        const {callBackfun} = callBackActions;
        typeof callBackfun === 'function' && callBackfun();
    }
}